/* eslint-disable */
'use strict';

module.exports = app => {
  const { DATE, STRING, TEXT, BOOLEAN, BIGINT,ENUM } = app.Sequelize;

  const Outfit = app.model.define('outfit', {
    id: {  
      type: BIGINT,
      primaryKey: true,
      autoIncrement: true,
    },
    user_id: {  
      type: BIGINT,
      allowNull: false,  
    },
    title: {  // 搭配标题
      type: STRING(255),
      allowNull: false,
    },
    description: {  // 搭配描述
      type: TEXT,
      allowNull: true,
    },
    category_id: {  // 搭配类别
      type: BIGINT,
      allowNull: false,
    },
    image: { 
      type: STRING(255),
      allowNull: false,
    },
    designer_nickname: {  
      type: STRING(100),
      allowNull: true,
    },
    designer_signature: {  
      type: STRING(255),
      allowNull: true,
    },
    is_personal: {  
      type: BOOLEAN,
      defaultValue: false,  
    },
    approval_status: {  
      type: ENUM('pedding', 'approved','rejected'),
      allowNull: false,  
    },
    created_at: DATE,
    updated_at: DATE,
  }, {
    tableName: 't_outfit',  
  });

  Outfit.associate = function() {
    app.model.Outfit.belongsTo(app.model.User, {
      foreignKey: 'user_id',
      as: 'user',  
    });

    app.model.Outfit.belongsTo(app.model.Categories, {
      foreignKey: 'category_id',
      targetKey: 'id',
      as: 'categories',
    });
  };

  return Outfit;
};
